package com.example.config;

import com.example.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * @author 小岁
 * @version 2023/10/1 22:07
 */
@Configuration
public class WebMVCConfig implements WebMvcConfigurer {

    @Bean
    public LoginInterceptor loginInterceptor(){
        return new LoginInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        System.out.println("拦截器=====");
        registry.addInterceptor(loginInterceptor()).addPathPatterns("/**")
                //自己设置白名单
                .excludePathPatterns("/allCompany/**","/city/**","/GeekJ/**","/home/**","/jobSeeker/**","/sendMessage/**","/navUser/**","/RecruiterLogin/**","/JrLogin/**")
                .excludePathPatterns("/plugins/**","/views/**","/assets/**")
                .excludePathPatterns("/alipays/**");
    }

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
        resolvers.add(new HandlerArgsConfig());
    }

}
